import Router from '@koa/router';
import { AuthController } from '../../../controllers/system/authController';
import { validateDto } from '../../../middleware/validation';
import { AuthMiddleware } from '../../../middleware/authMiddleware';
import { RegisterDto, LoginDto } from '../../../dtos/system/UserDto';

const router = new Router();
const authController = new AuthController();
const authMiddleware = new AuthMiddleware();

// 用户注册
router.post('/register', validateDto(RegisterDto, { skipMissingProperties: true }), authController.register);

// 用户登录
router.post('/login', validateDto(LoginDto), authController.login);

// 获取当前用户信息（需要认证）
router.get('/me', authMiddleware.authenticate, authController.getCurrentUser);

// 刷新 token（需要认证）
router.post('/refresh', authMiddleware.authenticate, authController.refreshToken);

export default router;